$(function () {
    var dictKey = $.util.getRequest('dictKey');
    $.util.get($.util.getRequestJson('/dict/findByGroupKey.json'), {groupKey: "messageType"}, function (data) {
        var messageType = $('#messageType').combobox({
            valueField: 'dictKey',
            textField: 'dictText',
            prompt: '请选择查询类型',
            editable: false,
            data: data.rows
        });
        messageType.combobox('setValue', dictKey);
    });
    var accept = {};
    var fileNumLimit = 5;
    if (dictKey == 'activity') {
        // 只允许选择图片文件。
        accept = {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        };
        $('.activity').show();
        $('#attrName').text('活动海报');
        fileNumLimit = 1;
    }
    $("#attachedFile").webuploader({
        // 文件接收服务端。
        server: $.util.getRequestJson('/json/uploader.upload.json'),
        accept: accept,
        auto: true,//是否自动上传
        fileNumLimit: fileNumLimit, //限制多文件上传的个数
        fileSizeLimit: 1024 * 1024 * 10
    });

    $("#context").ueditor({
        height: 250,
        template: false,
        toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', '|', 'simpleupload', '|', 'horizontal', 'date', 'time'
        ]]
    });

    var id = $.util.getRequest('id');
    if (id) {
        var url = $.util.getRequestJson('/json/sysMessage.findById.json');
        $.util.get(url, {id: id}, function (data) {
            setTimeout(function () {
                $('#publishNotice').form('load', data.data);
            }, 100);
        });
    }
});